package org.domeos.framework.api.controller.alarm;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.domeos.basemodel.HttpResponseTemp;
import org.domeos.framework.api.controller.ApiController;
import org.domeos.framework.api.consolemodel.alarm.TemplateInfo;
import org.domeos.framework.api.service.alarm.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by baokangwang on 2016/4/13.
 */
@Controller
@RequestMapping("/api")
@Api("报警相关api")
public class TemplateController extends ApiController {

    @Autowired
    TemplateService templateService;

    @ApiOperation(value="报警模板",notes="查看所有报警模板")
    @ResponseBody
    @RequestMapping(value = "/alarm/template", method = RequestMethod.GET)
    public HttpResponseTemp<?> listTemplateInfo() {
        return templateService.listTemplateInfo();
    }

    @ApiOperation(value="创建报警模板")
    @ResponseBody
    @RequestMapping(value = "/alarm/template", method = RequestMethod.POST)
    public HttpResponseTemp<?> createTemplate(@RequestBody TemplateInfo templateInfo) {
        return templateService.createTemplate(templateInfo);
    }

    @ApiOperation(value="修改报警模板")
    @ResponseBody
    @RequestMapping(value = "/alarm/template", method = RequestMethod.PUT)
    public HttpResponseTemp<?> modifyTemplate(@RequestBody TemplateInfo templateInfo) {
        return templateService.modifyTemplate(templateInfo);
    }

    @ApiOperation(value="查看报警模板",notes="根据模板ID获取模板内容")
    @ResponseBody
    @RequestMapping(value = "/alarm/template/{id}", method = RequestMethod.GET)
    public HttpResponseTemp<?> getTemplateInfo(@PathVariable long id) {
        return templateService.getTemplateInfo(id);
    }

    @ApiOperation(value="删除报警模板",notes="根据模板ID删除模板内容")
    @ResponseBody
    @RequestMapping(value = "/alarm/template/{id}", method = RequestMethod.DELETE)
    public HttpResponseTemp<?> deleteTemplate(@PathVariable long id) {
        return templateService.deleteTemplate(id);
    }

}
